<%--yhb--%>
<%@ page language="java" pageEncoding="utf-8"%>
<%@page import="com.towker.core.util.TimeUtil"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>${sys.name}</title>
		<meta http-equiv="content-type" content="text/html; charset=utf-8" />
		<c:set var="ctx" value="${pageContext.request.contextPath}" />
		<c:set var="time" value="<%=TimeUtil.getCurrentTimeValue()%>" />
		<script type="text/javascript" src="${ctx}/scripts/jquery/jquery.js"></script>
		<script type="text/javascript" src="${ctx}/scripts/util/util.js"></script>
		<script type="text/javascript"
			src="${ctx}/scripts/tree/helper/TreeHelper.js"></script>

		<link type="text/css" rel="stylesheet"
			href="${ctx}/scripts/tree/zTreeStyle/zTreeStyle.css" />
		<link type="text/css" rel="stylesheet"
			href="${ctx}/scripts/tree/zTreeStyle/zTreeIcons.css" />
		<link type="text/css" rel="stylesheet"
			href="${ctx}/css/easyui/default/easyui.css" />
		<link type="text/css" rel="stylesheet"
			href="${ctx}/css/easyui/icon.css" />
		<link type="text/css" rel="stylesheet" href="${ctx}/css/list.css" />
		<style type="text/css">
.myframe {
	width: 100%;
	height: 100%;
}

#mainDiv {
	margin: 0;
	padding: 0px;
}

#topMenu {
	padding-left: 10px;
	padding-top: 5px;
	line-height: 100%;
	background-image: url(${ctx }/images/main/top_back.jpg)
}

#topMenu h1 {
	margin-top: 10px;
	font-size: 28px;
	font-family: 黑体;
	font-weight: bold;
}

#topMenu .logo {
	margin-top: 0px;
	padding-top: 0px;
	padding-right: 10px;
	float: right;
	width: 200px;
	height: 50px;
}
</style>
		<script type="text/javascript" src="${ctx}/scripts/jquery.js"></script>
		<script type="text/javascript"
			src="${ctx}/scripts/easyui/jquery.easyui.js"></script>
		<script type="text/javascript"
			src="${ctx}/scripts/tree/jquery-ztree-2.3.min.js"></script>
		<script type="text/javascript">
			alert(window.parent.window.dialogArguments.name);
			/**
				所有的全局变量说明：

				1. g_current_url - 父页面的当前的资源树中的在子页面框架页面里面的某个资源地址。

				2. setting - 资源树zTree的配置信息。

			*/
			
			/**
				所有脚本方法说明：
				1. setCURRENT_URL - 设置g_current_url的值。

				2. getCURRENT_URL - 获得g_current_url的值。

				3. 文档加载完成后的动作。

				4. clone - 拷贝对象(渲染树的核心方法)。

				5. zTreeOnClick - zTree的单击事件处理。event-zTree事件;treeId-树的id;treeNode-被单击的节点。

				6. autoSize - iframe和外边框高宽自适应。

				7. loadTree - 加载树(得到树的入口)。

				8. attachUrl - 给iframe设置src。(默认是给mainFrame)
				
			*/
			//父页面的当前的资源树中的在子页面框架页面里面的某个资源地址。

			var g_current_url="";
			//设置g_current_url的值。

			function setCURRENT_URL(url){
				g_current_url=url;
			}
			//获得g_current_url的值。

			function getCURRENT_URL(){
				return g_current_url;
			}
		
			//资源树zTree的配置信息。

			var setting={
				showLine:true
			};
			
			//文档加载完成后的动作。

			$(function(){
				$('body').layout('panel','west').panel({
						onCollapse:function(){
							autoSize();
						},
						onExpand:function(){
							autoSize();
						}
				});
				
				autoSize();
				loadTree();
			});
			
			//加载树(得到树的入口)。

			function loadTree2(){
				var setting1=clone(setting);
				setting1.callback={click:zTreeOnClick};
				setting1.treeNodeKey="id";
				setting1.treeNodeParentKey="pid";
				setting1.isSimpleData=true;
				
				var sysid="${sys.id}";
				var userid="${user.id}";
				var url="${ctx}/manage/rbac/res/getUserResTree.htm?sysid="+sysid+"&userid="+userid;
				url=url.getNewUrl();
				$.post(url,function(data){
					if(data=="[]"){
						//alert("您没有任何的资源！");
						return;
					}
					//data=[{id:"1",pid:"0",name:"用户管理",src:"",icon:"",open:"true"},{id:"2",pid:"1",name:"用户列表",src:"/manage/user/getUser.htm",icon:"scripts/tree/zTreeStyle/img/page.gif",open:"true"},{id:"3",pid:"0",name:"系统管理",src:"",icon:"",open:"true"},{id:"2070",pid:"2060",name:"日记列表",src:"/manage/test/getDiary.htm",icon:"",open:"true"},{id:"4",pid:"3",name:"子系统管理",src:"/manage/rbac/getSys.htm",icon:"scripts/tree/zTreeStyle/img/page.gif",open:"true"},{id:"3756",pid:"0",name:"部门管理",src:"",icon:"",open:"true"},{id:"2200",pid:"3",name:"角色资源管理",src:"/manage/rbac/addRoleRes.htm",icon:"",open:"true"},{id:"2201",pid:"3",name:"用户角色分配",src:"/manage/rbac/addRoleUser.htm",icon:"",open:"true"},{id:"2220",pid:"3",name:"数据字典管理",src:"/manage/dict/getDictionary.htm",icon:"",open:"true"},{id:"3789",pid:"3",name:"流程管理",src:"/manage/jbpm/getAllFlow.htm",icon:"",open:"true"},{id:"3807",pid:"3756",name:"部门列表",src:"/manage/user/getDeptTree.htm",icon:"",open:"true"},{id:"4503",pid:"3756",name:"部门员工分配",src:"/manage/user/addDeptUser.htm",icon:"scripts/tree/zTreeStyle/img/page.gif",open:"true"},{id:"4844",pid:"1",name:"我的下属",src:"/manage/user/getSubor.htm",icon:"",open:"true"},{id:"5441",pid:"3",name:"流程实例",src:"/manage/jbpm/getFlowState.htm",icon:"",open:"true"},{id:"6680",pid:"2060",name:"学生列表",src:"/manage/test/getStu.htm",icon:"scripts/tree/zTreeStyle/img/page.gif",open:"true"},{id:"7191",pid:"2060",name:"班级列表",src:"/manage/test/getClz.htm",icon:"scripts/tree/zTreeStyle/img/page.gif",open:"true"}];
					$("#treeLeft").zTree(setting1,clone(eval(data)));
				});
			}
			
			//拷贝对象(渲染树的核心方法)。
			function clone(jsonObj){
				var buf=null;
			    if (jsonObj instanceof Array) {
			        buf = [];
			        var i = jsonObj.length;
			        while (i--) {
			            buf[i] = clone(jsonObj[i]);
			        }
			        return buf;
			    }else if (typeof jsonObj == "function"){
			        return jsonObj;
			    }else if (jsonObj instanceof Object){
			        buf = {};
			        for (var k in jsonObj) {
			            buf[k] = clone(jsonObj[k]);
			        }
			        return buf;
			    }else{
			        return jsonObj;
			    }
			} 
			
			//zTree的单击事件处理。event-zTree事件;treeId-树的id;treeNode-被单击的节点。

			function zTreeOnClick(event,treeId,treeNode){
				var navSrc=treeNode.src;
				if(navSrc!=""){
					src=ctx+navSrc;
					attachUrl(src);
					setCURRENT_URL(navSrc);
				}
			}
			
			//iframe和外边框高宽自适应。
			function autoSize()
			{
				$("#mainFrame").css("width",$("#mainDiv").width())
				.css("height",$("#mainDiv").height()-5);
			}
			
			/**
			部门树的加载。
			*/
			$(function(){
				myTree.loadTree("treeLeft","${ctx}/manage/sys/dept/getDeptTree2.htm".getNewUrl(),false,
					function()
					{
						var url="${ctx}/manage/sys/user/getDeptUser.htm";
						var node=$("#treeLeft").tree("getSelected");
						var deptid=node.id;
						url+="?deptid="+deptid;
						url=url.getNewUrl();
						$("#mainFrame").attr("src",url);
						result=node;
					},
					onloadsuccess:function()
					{
						$("#treeLeft").tree("collapseAll");
					}
				);
			});
			
			$(function(){
				$("#div").height(415);
			});
  		</script>
	</head>
	<body class="easyui-layout">
		<div id="div" region="west" split="true" title="所有部门"
			style="width: 250px;">
			<ul id="treeLeft" class="tree"
				style="height: 410px; padding-top: 5px;">
		</div>
		<div id="mainDiv" region="center">
			<iframe id="mainFrame" frameborder="0" />
		</div>
	</body>
</html>